function trim(val)
{
	 return val.replace(/(^\s*)|(\s*$)/g, "");
}

function checkSub(){
	
	if(document.getElementById('auction_name').value==''){
		alert('活动名称不能为空');
		document.getElementById('auction_name').focus();
		return false;
	}

	var str = CKEDITOR.instances.auction_desc.getData();
	str = trim(str);
	if(str == ''){
		alert('活动描述不能为空');
		CKEDITOR.instances.auction_desc.focus();
		return false;
	}
	if(document.getElementById('good_id').value==''){
		alert('拍卖商品名不能为空');
		document.getElementById('good_id').focus();
		return false;
	}
	
	if(document.getElementById('start_date').value==''){
		alert('拍卖开始时间不能为空');
		document.getElementById('start_date').focus();
		return false;
	}
	
	if(document.getElementById('end_date').value==''){
		alert('拍卖结束时间不能为空');
		document.getElementById('end_date').focus();
		return false;
	}
		var patrn = /^[0-9]{1,30}$/; 
		var sp = $('#start_price').val();
			if(sp=="") {
				alert('起拍价不能为空');
				$('#start_price').focus();
				return false;
			}else if(!patrn.exec(sp)) {
				alert('起拍价只能是数字');
				$('#start_price').focus();
				return false;
			}
			var ap = $('#a_price').val();
			if(ap=="") {
				alert('一口价不能为空');
				$('#start_price').focus();
				return false;
			}else if(!patrn.exec(ap)) {
				alert('一口价只能是数字');
				$('#a_price').focus();
				return false;
			}
			if(parseInt(ap)<parseInt(sp)){
				alert('一口价不能小于起拍价');
				$('#a_price').focus();
				return false;
			}
			
			var rp = $('#rate_price').val();
			if(rp=="") {
				alert('加价幅度不能为空');
				$('#start_price').focus();
				return false;
			}else if(!patrn.exec(rp)) {
				alert('加价幅度只能是数字');
				$('#rate_price').focus();
				return false;
			}
			var mp = $('#margin').val();
			
			if(mp=="") {
				alert('保证金不能为空');
				$('#start_price').focus();
				return false;
			}else if(!patrn.exec(mp)) {
				alert('保证金只能是数字');
				$('#margin').focus();
				return false;
			}
	
	document.addForm.submit();
}

function search(){
	//TODO
	document.indexForm.submit();
}

function ss_searchGoods(){		
			var searchData = '';
			searchData = 's_goods_name='+$('#goods_name').val();
			$.ajax({
			   type: "POST",
			   url: "searchGoods.jsp",
			   data: searchData,
			   success: function(msg){
				 $("#goods_id").html(msg);
			   }
			 });
	 
}

function searchGoods(){		
			var searchData = '';
			searchData = 's_goods_name='+$('#s_good_name').val() + "&s_class_attr=" +$("#goods_type").val();
			$.ajax({
			   type: "POST",
			   url: "searchGoods.jsp",
			   data: searchData,
			   success: function(msg){
				 $("#good_id").html(msg);
			   }
			 });
	 
}

function testtest() {
	if(trim(document.getElementById('start_price').value)=='')
	{
      alert('起拍价不能为空!');
	  document.getElementById('start_price').focus();
      return false; 
	} else if(!start_price_Reg.test(trim(document.getElementById('start_price').value))){
			alert('起拍价必须为正整数!');
			document.getElementById('start_price').focus();
			return false;
	}
	
	if(document.getElementById('a_price').value==''){
		alert('一口价不能为空!');
		document.getElementById('a_price').focus();
		return false;
	} else if(!armReg.test(trim(document.getElementById('a_price').value))){
			alert('一口价必需为非负整数!');
			document.getElementById('a_price').focus();
			return false;
	}
	if(document.getElementById('rate_price').value==''){
		alert('加价幅度不能为空!');
		document.getElementById('rate_price').focus();
		return false;
	} else if(!armReg.test(trim(document.getElementById('rate_price').value))){
			alert('加价幅度必需为非负整数!');
			document.getElementById('rate_price').focus();
			return false;
	}
	if(document.getElementById('margin').value==''){
		alert('保证金不能为空');
		document.getElementById('margin').focus();
		return false;
	} else if(!armReg.test(trim(document.getElementById('margin').value))){
			alert('保证金必需为非负整数!');
			document.getElementById('margin').focus();
			return false;
	}
	
}
